<template>
  <div class="customer-balance-page">
    <div class="search-wrapper">
      <super-search :search-form="searchForm" :search-item-config="searchItemList" @search="searchHandle"></super-search>
    </div>
    <div class="content-wrapper">
      <super-table
        :height="tableHeight"
        ref="tableRef"
        :async="asyncTable"
        :loading="loading"
        :data="tableData"
        v-model:page="searchForm.pageNum"
        v-model:limit="searchForm.pageSize"
        :column="tableColumn"
        :total="searchForm.total"
        @change-page="getData"
        :hasPagination="true"
      >
        <template #tool>
          <a-button type="primary" @click="exportDataHandle">导出</a-button>
        </template>
        <template #action="{ row }">
          <a-button type="link" @click="detailsHandle(row)">详情</a-button>
        </template>
      </super-table>
    </div>

    <!-- 抽屉 -->
    <a-drawer class="custom-drawer" v-model:visible="drawerOpts.visible" :title="drawerOpts.title" :closable="true" @close="getData" :width="drawerOpts.width" placement="right">
      <component v-model:visible="drawerOpts.visible" :is="drawerOpts.component" :type="drawerOpts.type" :pass-data="drawerOpts.passData" @submit="drawerSubmitHandle"></component>
    </a-drawer>
  </div>
</template>

<script lang="ts">
import Details from "./components/details/index.vue";

export default {
  name: "CustomerBalance",
  components: {
    Details
  }
};
</script>

<script setup lang="ts">
import ModalHook from "@/hook/modalHook";
import InitHook from "./composables/initHook";
import OperationHook from "./composables/operationHook";
import { searchItemList } from "./data";
import TableHeightHook from "@/hook/tableHeightHook";
const { tableHeight, loading } = TableHeightHook(50);
const { searchForm, tableData, tableRef, tableColumn, asyncTable, drawerOpts } = InitHook();
const { getData, searchHandle, detailsHandle, exportDataHandle } = OperationHook({ searchForm, tableData, loading, tableColumn, asyncTable, drawerOpts, tableRef });
const { drawerSubmitHandle } = ModalHook({
  drawerOpts,
  callBack: searchHandle
});
searchHandle();
</script>
<style lang="stylus" scoped></style>
